package com.atcper

import scala.language.postfixOps

/**
 * @author : ranzlupup
 * @date : 2023/2/22 08:39
 */
object Scala07_function_hell {
    def main(args: Array[String]): Unit = {

        def compute(x: Int, f: (Int, Int) => Int, y: Int): Int = {
            f(x, y)
        }

        def sum(x: Int, y: Int): Int = {
            x + y
        }

        println(compute(4, sum, 1))
        compute(4, (x: Int, y: Int) => {
            x + y
        }, 6)

        compute(4, (x, y) => x + y, 6)

        println(compute(4, _ + _, 6))

        ifTest1()
        println("/////////////")
        ifTest2()

    }

    private def ifTest1() : Unit = {
        // for (i <- 1 to 3 if i != 2) {
        //     println(i)
        // }
        // for (i <- 1 to 3; j <- 1 to 3) {
        //
        //     println(" i =" + i + " j = " + j)
        //
        // }

        val res = for (i <- 1 to 10) yield i*2

        println(res)

        for (i <- 1 to 10 reverse) {

            println(i)

        }
    }

    private def ifTest2() = {
        for (i <- 1 until 3) {
            if (i != 2) {
                println(i)
            }
        }
    }
}
